package TextField
{
	import com.greensock.TweenLite;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class TestMenuTip extends Sprite
	{
		private var menu:Sprite;
		private var menu1:Sprite;
		private var menu2:Sprite;
		public function TestMenuTip()
		{
			super();
			init();
		}
		
		public function init():void {
			menu = new Sprite();
			menu.graphics.beginFill(0x0,.7);
			menu.graphics.drawRect(0,0,20,20);
			menu.graphics.endFill();
			menu.x = 100;
			menu.y = 100;
			this.addChild(menu);
			
			menu1 = new Sprite();
			menu1.graphics.beginFill(0x0,.7);
			menu1.graphics.drawRect(0,0,20,20);
			menu1.graphics.endFill();
			menu1.x = 100;
			menu1.y = 130;
			this.addChild(menu1);
			
			menu2 = new Sprite();
			menu2.graphics.beginFill(0x0,.7);
			menu2.graphics.drawRect(0,0,60,20);
			menu2.graphics.endFill();
			menu2.x = 200;
			menu2.y = 50;
			this.addChild(menu2);
			
			var tip:MenuTip = new MenuTip("hello world errrrrrrrrrrrrr");
			this.addChild(tip);
			tip.x = 200;
			tip.y = 200;
			menu.addEventListener(MouseEvent.MOUSE_OVER,onMouseOver);
		}
		
		public function onMouseOver(event:MouseEvent):void {
			var tip:MenuTip = new MenuTip("hello world sdfdfdf");
			tip.x = menu.x;
			tip.y = menu.y;
			tip.alpha = .1
			this.addChild(tip);
			TweenLite.to(tip,.4,{x:tip.x+menu.width+10,alpha:1});
			menu.addEventListener(MouseEvent.MOUSE_OUT,onMouseOut(tip,this));
		}
		
		public function onMouseOut(tip:MenuTip,parent:Sprite):Function {
			return function(event:MouseEvent):void {
				if(parent.contains(tip))
					parent.removeChild(tip);
			}
		}
	}
}